<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>Hello APP</title>
<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../../css/common.css" />
<style>
.aui-content{
	padding: 1rem;
}
.tit{
	font-size: 1.2rem;
	font-weight: bold;
}
.block{
	width: 0.3rem;
	height: 0.3rem;
	display: inline-block;
	background-color: #363335;
	margin-right: 0.2rem;
}
.pt-36{
	padding-top: 1.8rem;
}
.info-list{
	font-size: 0.7rem;
}
dl.comFlexItem dt {
		width: 5rem;
}
dl.comFlexItem{
	padding-top: 0.25rem;
}
select,
input.textInput {
		font-size: 0.7rem;
		height: 2rem;
}
.comFlexItem select,
.comFlexItem input.textInput {
		text-align: right;
		padding: 0 0.5rem;
}
.bom-tit{
	padding-top: 1.1rem;
	font-size: 0.6rem;
	color: #999999;
}
.comBox{
	position: fixed;
	bottom: 1rem;
	border-radius: 5rem;
	padding: 0 1rem;
	width: 100%;
}
.comBtmBtn{
	height: 2.5rem;
	line-height: 2.5rem;
	border-radius: 5rem;
}
</style>
</head>
<body>
	<div class="aui-content">
		<div class="tit color-000">提现账号设置</div>
		<div class="pt-36 aui-font-size-12 color-555"><span class="block"></span>实名信息</div>
		<div class="info-list">
			<dl class="comFlexItem aui-border-b">
				<dt>姓名</dt>
				<dd class="flex-auto"><input type="text" id="name" name="" value="" placeholder="请输入真实姓名" class="textInput"></dd>
			</dl>
			<dl class="comFlexItem aui-border-b">
				<dt>身份证号码</dt>
				<dd class="flex-auto"><input type="text" id="card" name="" value="" placeholder="请输入正确的身份证号" class="textInput"></dd>
			</dl>
		</div>
		<div class="pt-36 aui-font-size-12 color-555"><span class="block"></span>账户设置</div>
		<div class="info-list">
			<dl class="comFlexItem aui-border-b">
				<dt>支付宝账号</dt>
				<dd class="flex-auto"><input type="text" id="number" name="" value="" class="textInput"  placeholder="请输入支付宝账号"></dd>
			</dl>
			<dl class="comFlexItem aui-border-b">
				<dt>确认支付宝账号</dt>
				<dd class="flex-auto"><input type="text" id="numberYes" name="" value="" class="textInput" placeholder="请输入支付宝账号"></dd>
			</dl>
		</div>
		<div class="bom-tit">
			*支付宝号码的格式为手机号码或邮箱，若这两者您都有，则优先填写为邮箱的支付宝账号。
		</div>

	</div>
	<div class="comBox">
		<div class="comBtmBtn" tapmode onclick="save()">保存</div>
	</div>
</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
var userId;
var userInfo;
apiready = function(){
	api.parseTapmode();
	userId = getUserId();
	userInfo = getUserinfo();
	if(userInfo.user_name){
		$$('#name').val(userInfo.user_name)
	}
	if(userInfo.data_card_no){
		$$('#card').val(userInfo.data_card_no)
	}
};
var reg = /(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
var email = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
function save(){
	var name = $$('#name').val();
	var card = $$('#card').val();
	var number = $$('#number').val();
	var numberYes = $$('#numberYes').val();
	if(!name){
		toast('请填写姓名')
	}
	var cardLength = 18;
	if(!card){
		toast('请填写"身份证号"');
		return false;
	}else if(card.length != cardLength){
		toast('身份证账号有误');
		return false;

	}

	if(!number){
		toast('请填写 "支付宝账号" ');
		return false;

	}
	if(!reg.test(number) && ! email.test(number)){
		toast('支付宝账号格式有误');
		return false;

	}
		if(!numberYes){
			toast('请确认支付宝账号');
			return false;

		}else if(numberYes != number){
			toast('确认支付宝账号有误');
			return false;


		}
	var postData = {};
	postData.name = name;
	postData.card_no = card;
	postData.account = number;
	postData.userid = userId;
	api.ajax({
	    url: BASE_URL + 'App/User/setAliAccount',
	    method: 'post',
	    data: {
	        values: postData
	    }
	},function(ret, err){
	    if (ret && ret.code == 1) {
					toast("设置成功");
					api.sendEvent({
					    name: 'guanEvent'
					});
					api.closeWin()
	        setTimeout(function(){
						api.openWin({
						    name: 'ti_amount_win',
						    url: 'ti_amount_win.html',
						    pageParam: {
										name: name,
										account: number
						    }
								})
						},500);

	    } else {
				toast(ret.msg)
	    }
	});



}
</script>
</html>
